<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt" %>
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title><spring:message  code="pim"/> - <spring:message  code="homepage.project"/>&nbsp;
       <c:out value="${bean.project.name}"></c:out> - <spring:message  code="project.task.detail" />&nbsp;#${task.code}</title>
<link href="<%= request.getContextPath() %>/css/custom.css" rel="stylesheet" type="text/css" />
<link href="<%= request.getContextPath() %>/css/style.css" rel="stylesheet" type="text/css" />
<link href="<%= request.getContextPath() %>/css/v.css" rel="stylesheet" type="text/css" />
<link href="<%= request.getContextPath() %>/css/jquery.ui.all.css" rel="stylesheet" />
<script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery-1.6.2.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery-ui-1.8.14.custom.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/js/common.js"></script>
<%@include file="script/pim-util.jsp" %>
<%@include file="script/sort-table.jsp" %>
<script type="text/javascript">
var TSort_Data = new Array ('mytable', 's','s','s', 's');
tsRegister();
</script>
<style type="text/css">
input,select {
	width: 200px;
}
a img {
	border: 0 none;
}
</style>
</head>
<body>
<% try{ %>
<c:if test="${bean.isSigned}">
<div id="all">
<div id="wrapper">
<div id="mainheader">
	<jsp:include page="include/common/headerSignedIn.jsp" />
</div> 
<div id="content-wrapper">
<div id="top-menu">
    <jsp:include page="include/common/topMenuHome.jsp" />
</div>
<div class="main-content">
<form:form action="" method="post" name="task" commandName="task">	   		  
<div>
	<div class="v-row">
		<div class="v-row-left" style="margin-left: 10px;">
			<span class="v-title">
				<spring:message  code="project.task.detail" />
			</span>			
	        <span class="other-formats">Export to : <a rel="nofollow" class="pdf" href="${bean.pdfFilePath}">PDF</a></span>
		</div>	
		<c:set value="tasks.htm?pnum=${bean.project.number}" var="url"/>  
		<div style="float: right;">
			<a href='<c:out value="${url}" />' style="padding-right: 10px;color: blue;text-decoration:none;"> 
				[<spring:message code="back.to.project.homepage" />]</a>
		</div>		
	</div>
	
	<div class="v-row" id="v-global-message"></div>
	
	<div class="v-row">	
	<table cellspacing="1" class="width100 v-table">
		<tbody>
		<tr class="v-table-header">
			<td width="15%"><spring:message  code="title.task.id" /></td>
			<td width="20%"><spring:message  code="title.task.category" /></td>
			<td width="20%"><spring:message  code="title.task.severity" /></td>
			<td width="15%"><spring:message  code="title.task.date.submitted" /></td>
			<td width="15%"><spring:message  code="title.task.date.last.update" /></td>
		</tr>
		
		<tr class="v-table-row-0">
			<td><c:out value="${task.code}" /></td>
			<td><c:out value="${task.taskCategory.name}" /></td>
			<td><c:out value="${task.taskSeverity.name}" /></td>			
			<td><fmt:formatDate pattern="yyyy-MM-dd hh:mm" value="${task.createdtime}" /></td>
			<td><fmt:formatDate pattern="yyyy-MM-dd hh:mm" value="${task.lastchanged}" /></td>
		</tr>
				
		<tr class="v-table-row-1">
			<td><spring:message code="task.reporter" /></td>
			<td colspan="5"><c:out value="${task.reporter}" /></td>
		 </tr>
		
		<tr class="v-table-row-0">
			<td><spring:message code="task.monitoredby" /></td>
			<td colspan="5">
			    <c:set value="${task.monitoredby}" var="monitoredby"/>
			    <c:choose>
				     <c:when test="${monitoredby != '' && monitoredby != null}">
				       <c:out value="${task.monitoredby}" />
				     </c:when>
				     <c:otherwise>
				       <spring:message  code="title.undefined" />
				     </c:otherwise>
			    </c:choose>		   
			</td>
		</tr>
		
		<tr class="v-table-row-1">
			<td><spring:message code="task.assignedto" /></td>
			<td colspan="5">
			    <c:set value="${task.assignedto}" var="assignedto"/>
			    <c:choose>
				     <c:when test="${assignedto != '' && assignedto != null}">
				       <c:out value="${task.assignedto}" />
				     </c:when>
				     <c:otherwise>
				        <spring:message  code="title.undefined" />
				     </c:otherwise>
			    </c:choose>		   
			</td>
		</tr>
		
		<tr class="v-table-row-0">
			<td><spring:message code="title.task.priority" /></td>
			<td colspan="5"><c:out value="${task.taskPriority.name}" /></td>
		</tr>
		
		<tr class="v-table-row-1">
			<td><spring:message code="task.status" /></td>
			<td colspan="5"><c:out value="${task.taskStatus.name}" /></td>			
		</tr>
		
		<tr class="v-table-row-0">
			<td><spring:message code="title.task.summary" /></td>
			<td colspan="5"><c:out value="${task.summary}" /></td>
		</tr>
	
		<tr class="v-table-row-1">
			<td><spring:message code="title.task.description" /></td>
			<td colspan="5">${task.description}</td>
		</tr>		
		
		<tr class="v-table-row-0">
			<td><spring:message code="task.additionalinformation" /></td>
			<td colspan="5">${task.additionalinformation}</td>
		</tr>
		
		<tr class="v-table-row-1">
			<td><spring:message code="task.percent.completed" /></td>
			<td colspan="5">
			    <c:set value="${task.percentcomplete}" var="percentcomplete"/>
				    <c:choose>
					     <c:when test="${percentcomplete != null}">
					       <table style="width: 180px;height: 20px;" class="progress">
					        <tbody>
					         <tr><td style="width: 100%;" class="closed"></td></tr>
					       </tbody>
					       </table>
					       <p class="pourcent"><c:out value="${task.percentcomplete}" />%</p>				       
					     </c:when>
					     <c:otherwise>
					       <table style="width: 180px;height: 20px;" class="progress">
					        <tbody>
					         <tr><td style="width: 100%;" class="todo"></td></tr>
					       </tbody>
					       </table>
					       <p class="pourcent">0%</p>
					     </c:otherwise>
				</c:choose>				   
			</td>
		</tr>
			
		<tr class="v-table-row-0">
			<td><spring:message code="task.actual.hours" /></td>
			<td colspan="5"><c:out value="${task.actualtime}" /></td>
		</tr>
		
		<tr class="v-table-row-1">
			<td><spring:message code="task.estimate.hours" /></td>
			<td colspan="5"><c:out value="${task.estimatetime}" /></td>
		</tr>
								
		<tr class="v-table-row-0">
			<td><spring:message code="title.task.starttime"/></td>
			<td colspan="5"><fmt:formatDate pattern="yyyy-MM-dd" value="${task.starttime}" /></td>
		</tr>
		
		<tr class="v-table-row-1">
			<td><spring:message code="title.task.endtime"/></td>
			<td colspan="5"><fmt:formatDate pattern="yyyy-MM-dd" value="${task.endtime}" /></td>
		</tr>
		
		<tr class="v-table-row-0">
			<td><spring:message code="task.phase" /></td>
			<td colspan="5"><c:out value="${task.phase}" /></td>	
		</tr>
		
		<tr class="v-table-row-1">
			<td><spring:message code="task.note" /></td>
			<td colspan="5">${task.note}</td>	
		</tr>
		  
		<tr class="v-table-row-0 v-row-center">	       
		    <td colspan="6">
				<input type="button" class="bt-form"  
				       onclick="redirectToPage('<c:out value='${bean.updatePageUrl}'/>')"
					   value="<spring:message code="button.update" />"/>
		    			
				<input type="button" class="bt-form"
					   onclick="cancel('<c:out value='${bean.returnToFullPageURL }'/>')"
					   value="<spring:message code="button.back"/>" />
		    </td>		    
		</tr>		      
    </tbody>
    </table>
	</div>						
</div>

<c:if test="${bean.isAttached}">
<div class="attachments">	
    <p><span><spring:message code="task.attachedfiles" /></span></p>
    <c:forEach items="${bean.resources}" var="resource">		
    <p>
        <a class="icon icon-attachment" href="${resource.path}">${resource.orignalName}</a>	       
	    <span class="size">(<fmt:formatNumber value="${resource.size}" maxFractionDigits="1"/> KB)</span>
	    <span class="author">${resource.author}, <fmt:formatDate pattern="yyyy-MM-dd  hh:ss" value="${resource.createdAt}" /></span>
	</p>		
	</c:forEach>	
    <c:forEach items="${bean.resources}" var="resource">
	<div class="images">		
		<a title="${resource.orignalName}" rel="attachments" class="lightbox" href="${resource.path}">
		  <img src="${resource.path}" alt="${resource.orignalName}">
		</a>		
	</div>
	</c:forEach>
</div>
</c:if>

<c:if test="${bean.hasParent}">
<div id="issue_tree">
<p><strong><spring:message code="title.project.parent.task" /></strong></p>
<ul>
<c:forEach items="${task.tasksForTaskid}" var="taskParent">
  <li><a href="taskDetail.htm?pnum=${bean.project.number}&tcode=${taskParent.code}">#${taskParent.code}&nbsp;(${taskParent.taskStatus.name})&nbsp;${taskParent.summary}</a></li>
</c:forEach>
</ul>
</div>
</c:if>

<div id="issue_tree">
<div class="contextual">
  <a href="addTasks.htm?pnum=${bean.project.number}&parent_tcode=${task.code}">+ <spring:message code="button.add" /></a>
</div>
<p><strong><spring:message code="title.project.sub.task" /></strong></p>
<ul>
<c:forEach items="${task.tasksForTaskchildid}" var="taskChild">
  <li><a href="taskDetail.htm?pnum=${bean.project.number}&tcode=${taskChild.code}">#${taskChild.code}&nbsp;(${taskChild.taskStatus.name})&nbsp;${taskChild.summary}</a></li>
</c:forEach>
</ul>
</div>

<div style="display: none;" id="history_closed">
	<table cellspacing="0" class="width100 v-table" style="margin-bottom: 30px;">
		<tbody>
			<tr>
				<td colspan="4">
					<a onclick="ToggleDiv( 'history', g_div_history ); return false;" href="">
					   <img border="0" alt="+" src="<%=request.getContextPath()%>/images/plus.png">
					</a>
					<spring:message code="task.history" />	
				</td>
			</tr>
		</tbody>
	</table>
</div>
<br/>
<div id="history_open">
	<table id="mytable" cellspacing="0" class="width100 v-table" style="margin-bottom: 30px;">
		<tbody>
			<tr>
				<td colspan="4">
					<a onclick="ToggleDiv( 'history', g_div_history ); return false;" href="">
					   <img border="0" alt="-" src="<%=request.getContextPath()%>/images/minus.png">
					</a>
					<spring:message code="task.history" />	
				</td>
			</tr>
			<tr class="v-table-header">
				<td style="width: 20%;"><spring:message code="title.modified.time" /></td>
				<td style="width: 15%;"><spring:message code="title.username" /></td>
				<td style="width: 20%;"><spring:message code="title.field" /></td>
				<td style="width: 45%;"><spring:message code="title.change" /></td>
			</tr>
			<c:forEach items="${bean.logs}" var="log" varStatus="count">
			<tr class="${count.count % 2 != 0 ? 'v-table-row-0' : 'v-table-row-1'}">
				<td scope="row" class="v-text-cell">
				    <fmt:formatDate pattern="yyyy-MM-dd hh:mm" value="${log.time}" />
				</td>							
				<td scope="row" class="v-text-cell">
				   <c:out value="${log.visa}" />
				</td>							
				<td scope="row" class="v-text-cell"><spring:message code="${log.field}" /></td>							
				<td scope="row" class="v-text-cell">
				    <c:out value="${log.change}" />
				</td>														   
			</tr>
			</c:forEach>
		</tbody>
	</table>
</div>
<input type="hidden" name="updatePageUrl" value="${bean.updatePageUrl}"/>
<input type="hidden" name="pnum" value="${bean.project.number}"/>
<input type="hidden" name="returnToFullPageURL" value="${bean.returnToFullPageURL}"/>
</form:form>	
</div>	
</div>
<div class="footer">
	<jsp:include page="include/common/footer.jsp" />
</div>
</div>
</div>
</c:if>
<% } catch(RuntimeException re){ re.printStackTrace(); } %>
</body>
</html>